public class HashBuck2<K, V> {
    private static class Node<K, V>{
        private final K key;
        private V value;
        private Node<K, V> next;
        public Node(K key, V value){
            this.key = key;
            this.value = value;
        }
    }
    private Node<K, V>[] array;
    private int size;
    public HashBuck2(){
        this.array = new Node[10];
    }
    public void put(K key, V value){
        Node<K, V> node = new Node<>(key, value);
        int hash = node.hashCode();
        int index = hash % array.length;
        Node<K, V> cur = array[index];
        while(cur != null){
            if(cur.key.equals(key)){
                cur.value = value;
                return;
            }
            cur = cur.next;
        }
        this.size++;
        //检查负载因子，超出了需要重新哈希
    }
    public V get(K key){
        int hash = key.hashCode();
        int index = hash % this.array.length;
        Node<K, V> cur = this.array[index];
        while(cur != null){
            if(cur.key.equals(key)){
                return cur.value;
            }
            cur = cur.next;
        }
        return null;
    }
}
